package com.huatai.bi.controller;

import com.huatai.bi.dto.DataProcessDto;
import com.huatai.bi.dto.GroupCollectMergeDto;
import com.huatai.bi.service.DataProcessService;
import com.huatai.bi.service.GroupCollectMergeService;
import com.huatai.common.api.R;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @author : zhangbenting
 * @date : 2024/6/27 19:22
 * @Version: 1.0
 */
@RestController
@Api(value = "分组汇总合并", tags = "分组汇总合并")
@RequestMapping("/groupCollectMerge")
public class GroupCollectMergeController {

    @Autowired
    private GroupCollectMergeService groupCollectMergeService;

    @Autowired
    private DataProcessService dataProcessService;


    @GetMapping("/getDataProcessId")
    @ApiOperation(value = "获取数据加工id", notes = "获取数据加工id")
    public R<Long> getDataProcessId(@RequestParam Long dtId) {
        return R.data(dataProcessService.getDataProcessId(dtId));
    }

    @PostMapping("/saveDataProcess")
    @ApiOperation(value = "新增加工主表信息", notes = "新增加工主表信息")
    public R<Boolean> saveDataProcess(@RequestBody DataProcessDto dataProcessDto) {
        return R.data(dataProcessService.saveDataProcess(dataProcessDto));
    }

    @PostMapping("/getGroupCollectMergePreview")
    @ApiOperation(value = "获取分组、汇总、合并预览", notes = "获取分组、汇总、合并预览")
    public R getGroupCollectMergePreview(@RequestBody GroupCollectMergeDto groupCollectMergeDto) {
        return R.data(groupCollectMergeService.getGroupCollectMergePreview(groupCollectMergeDto));
    }

    @PostMapping("/saveGroupCollectMerge")
    @ApiOperation(value = "新增分组、汇总、合并", notes = "新增分组、汇总、合并")
    public R<Boolean> saveGroupCollectMerge(@RequestBody GroupCollectMergeDto groupCollectMergeDto) {
        return R.data(groupCollectMergeService.saveGroupCollectMerge(groupCollectMergeDto));
    }

    /**
     * 判断公式是否合规
     */
    @PostMapping("/formulaWhetherCompliance")
    @ApiOperation(value = "判断是否合规", notes = "判断是否合规")
    public R<Boolean> formulaWhetherCompliance(@RequestBody GroupCollectMergeDto groupCollectMergeDto) {
        return R.data(groupCollectMergeService.formulaWhetherCompliance(groupCollectMergeDto));
    }

}
